# This is a template of a simple template of a fcitx module with name "example"
# Please remember to replace all "[Ee]xample"'s in the files and file names
# to your addon's real name.
cmake_minimum_required(VERSION 2.8.11)

project(fcitx-shuoxie)
#SET(CMAKE_C_COMPILER "g++")  #选择编译器，默认是gcc
#set(CMAKE_INSTALL_PREFIX "/usr")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})


find_package(Fcitx 4.2.7 REQUIRED)
find_package(PkgConfig REQUIRED)

pkg_check_modules(DBUS "dbus-1" REQUIRED)
pkg_check_modules(DBUS_GLIB "dbus-glib-1" REQUIRED)


set(BINDIR /usr/bin)
set(DATADIR ${CMAKE_INSTALL_PREFIX}/share)
set(LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)

# This will add a uninstall target. Comment out this line if other cmake packages
# you are using already provides such target (e.g. KDE).
_fcitx_add_uninstall_target()
include_directories(${FCITX4_FCITX_INCLUDE_DIRS})
include_directories(${FCITX4_FCITX_CONFIG_INCLUDE_DIRS})
include_directories(${FCITX4_FCITX_UTILS_INCLUDE_DIRS})
include_directories("${PROJECT_BINARY_DIR}")

set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter  -fvisibility=hidden ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter  -fvisibility=hidden ${CMAKE_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_MODULE_LINKER_FLAGS}")
add_definitions("-DLOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/share/locale\"")

configure_file(config.h.in config.h
  IMMEDIATE @ONLY)

# The po dir (and targets, if any) should be added before any other translate
# related sources are processed.

add_subdirectory(data)
add_subdirectory(po)
add_subdirectory(src)



#准备的版本设置  
  
set(_VERSION_MAJOR 1)  
set(_VERSION_MINOR 0)  
set(_VERSION_PATCH 0)  
  
#说明要生成的是deb包  
  
set(CPACK_GENERATOR "DEB")  
  
############下面是设置debian/control文件中的内容  
  
#设置版本信息  
set(CPACK_PACKAGE_VERSION_MAJOR "${_VERSION_MAJOR}")  
set(CPACK_PACKAGE_VERSION_MINOR "${_VERSION_MINOR}")  
set(CPACK_PACKAGE_VERSION_PATCH "${_VERSION_PATCH}")  
  
#设置安装包的包名，打好的包将会是packagename-version-linux.deb，如果不设置，默认是工程名  
set(CPACK_PACKAGE_NAME "fcitx-shuoxie")  
  
#设置程序名，就是程序安装后的名字  
set(CPACK_DEBIAN_PACKAGE_NAME "fcitx-shuoxie")  
  
#设置架构  
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")  
  
#设置依赖  
set(CPACK_DEBIAN_PACKAGE_DEPENDS "fcitx,dbus")  
  
#设置section  
set(CPACK_DEBIAN_PACKAGE_SECTION "net")  
  
#设置priority  
set(CPACK_DEBIAN_PACKAGE_PRIORITY "Optional")  
  
#设置description  
set(CPACK_PACKAGE_DESCRIPTION "fcitx-shuoxie ")  
  
#设置联系方式  
set(CPACK_PACKAGE_CONTACT "hebinq@qq.com")  
  
#设置维护人  
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "hebinq@qq.com")  
  
#最后 别忘记最重要的  我们使用cpack工具来实现打包工作的  
include(CPack)
